package com.ailk.aee.pcc.server;

import com.ailk.aee.pcc.dao.UserTargetDao;
import com.ailk.aee.pcc.utils.CacheUtils;
import com.mongodb.DBObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author pengzhang
 */
@Service
public class UserTargetServer {

    private UserTargetDao userTargetDao;

    public DBObject queryUserTargetInfo(String userId, String targetKey, String channelName) {
        String cacheKey = CacheUtils.getTargetCacheName(channelName, targetKey);
        return userTargetDao.queryUserTarget(userId, cacheKey, channelName);
    }

    public void addUserTarget(String userId, String targetKey, String channelName, String value) {
        String cacheKey = CacheUtils.getTargetCacheName(channelName, targetKey);
        userTargetDao.addUserTarget(userId, cacheKey, value, channelName);
    }

    public void addBatchTarget(String targetKeys, String value) {
        userTargetDao.addBatchUserTarget(targetKeys, value);
    }

    /**
     * 删除用户指标记录
     *
     * @param userId
     * @param channelName
     */
    public void deleteUserTarget(String userId, String channelName) {
        userTargetDao.deleteUserTarget(userId, channelName);
    }
}
